< previous page page_584 next page >

Page 584
0584-01.jpg
Figure 26.6
The Search button presents the users with
an opportunity to enter search conditions.
4. Add the following code to the Click event procedure of cmdSeek:
    Dim sBkmark As Variant, sSeek As String
    rsTitles.Index = "Title"
    sBkmark = rsTitles.Bookmark
    sSeek = UCase(txtSearch.Text)
    rsTitles.Seek ">=", sSeek
    If rsTitles.NoMatch Then
        MsgBox "No match!"
        rsTitles.Bookmark = sBkmark
    Else
        If UCase(Left(rsTitles!Title, Len(sSeek))) <> sSeek Then
            MsgBox "No match!"
            rsTitles.Bookmark = sBkmark
        End If
    End If
    ShowFields
Using the PercentPosition and AbsolutePosition Properties
In addition to the Bookmark property, the Recordset object has two other properties that you can set to establish the position of the record pointer. These properties are PercentPosition and AbsolutePosition.
The PercentPosition property specifies the approximate position in a recordset where a record is located. By setting this property to a value between 0 and 100, you cause the pointer to move to the record closest to that location. Setting the property to a value outside the range causes an error to occur. You can use the PercentPosition property with all three types of recordsets.
The AbsolutePosition property enables you to tell the recordset to move to a specific record. The value of the property can range from 0 for the first record in the recordset to 1 less than the number of records. Setting a value outside that range causes an error. Therefore, including error checking in the code used to set the AbsolutePosition property is a good idea. The AbsolutePosition property can be used only with dynasets and snapshots. The following code shows how you can use the AbsolutePosition and PercentPosition properties. Note the validation of the requested position; it is used to prevent errors:

 
< previous page page_584 next page >